package com.xqboss.apps.service.marketing;

import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xqboss.apps.domain.marketing.MarketingAirdropMaterialRecord;
import com.xqboss.apps.dto.marketing.GetAirdropRecordListDto;
import com.xqboss.apps.mapper.marketing.MarketingAirdropMaterialRecordMapper;
import com.xqboss.apps.vo.marketing.AirdropMaterialRecordExportVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 空投-材料(热豆/扳手...)记录 服务实现类
 * </p>
 *
 * @author 木鱼
 * @since 2024-02-22
 */
@Service
@Slf4j
public class MarketingAirdropMaterialRecordService extends ServiceImpl<MarketingAirdropMaterialRecordMapper, MarketingAirdropMaterialRecord> {

    /**
     * 根据批量空投材料id获取空投材料记录
     * @param airdropMaterialId
     * @return
     */
    public List<MarketingAirdropMaterialRecord> getAirdropMaterialRecord(Long airdropMaterialId) {
        return this.list(new LambdaQueryWrapper<MarketingAirdropMaterialRecord>().eq(MarketingAirdropMaterialRecord::getAirdropMaterialId, airdropMaterialId));
    }

    /**
     * 导出空投材料记录
     * @param params
     * @return
     */
    public List<AirdropMaterialRecordExportVo> export(GetAirdropRecordListDto params) {
        params.startOrder();
        params.setPageSize(null);
        List<MarketingAirdropMaterialRecord> voList = getAirdropMaterialRecord(params.getAirdropId());
        List<AirdropMaterialRecordExportVo> res = BeanUtil.copyToList(voList, AirdropMaterialRecordExportVo.class);
        return res;
    }
}